import roslibpy

class SetUserMode:

    def __init__(self, framework):
        self.framework = framework
        self.talker = None
        self.user_mode = 0

    def set(self, user_mode):
        if self.framework.framework.utils.device.device_state:
            self.user_mode = user_mode
            self.talker = roslibpy.Topic(self.framework.framework.utils.device.device_connect, "/alphadog_node/set_user_mode", "ros_alphadog/SetUserMode")
            if self.user_mode > 0:
                self.talker.publish(roslibpy.Message({"user_mode": self.user_mode}))
            self.end()

    def end(self):
        self.user_mode = 0
